/*
 * Copyright (c) 2023 Huawei Technologies Co., Ltd.
 * openUBMC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

#include "awm_m11p_gpu.h"
#include "mc/log.h"

namespace dev {

// 实现gpu的虚函数
bool awm_m11p_gpu::start() {
    return true;
}

// 实现gpu的虚函数
bool awm_m11p_gpu::stop() {
    return true;
}

// 实现gpu的虚函数
bool awm_m11p_gpu::init(mc::mutable_dict& config, const mc::dict& connector) {
    try {
        from_variant(config, *this);
    } catch (const std::exception& e) {
        elog("awm_m11p_gpu init failed, exception: ${exception}", ("exception", e.what()));
        return false;
    }
    return true;
}

bool awm_m11p_gpu::reset_default_properties() {
    m_processor.Presence                = false;
    m_gpu.InfoRomVersion                = "";
    m_gpu.BuildDate                     = "";
    m_gpu.UUID                          = "";
    m_gpu.Utilization                   = 0;
    m_gpu.TemperatureCelsius            = 0;
    m_gpu_power.PowerWatts              = 0;
    m_gpu_power.PowerBrakeState         = 255;
    m_gpu_power.ExternalPowerSufficient = 255;
    m_gpu_status.ECCModeEnabled         = 255;
    m_gpu_status.ECCModePendingEnabled  = 255;
    m_gpu_status.ResetRequired          = 255;

    return true;
}

} // namespace dev

MC_REFLECT(dev::awm_m11p_gpu,
           ((m_processor, "bmc.dev.Processor"))((m_gpu, "bmc.dev.Gpu"))(
               (m_gpu_power, "bmc.dev.Gpu.Power"))((m_gpu_status, "bmc.dev.Gpu.Status")))